﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WeatherClock.Data;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;

namespace WeatherClock.VariableTemplate
{
    public class VariableTiles:DataTemplateSelector
    {
        public DataTemplate WeatherTemplate { get; set; }
        public DataTemplate WorldClockTemplate { get; set; }
        public DataTemplate MoreTemplate { get; set; }

        protected override Windows.UI.Xaml.DataTemplate SelectTemplateCore(object item, Windows.UI.Xaml.DependencyObject container)
        {
            FrameworkElement element = container as FrameworkElement;
            if(item != null && element !=null)
            {
                if((item as HubPageDataItem).UniqueId.StartsWith("Weather"))
                    return WeatherTemplate;
                if ((item as HubPageDataItem).UniqueId.StartsWith("WorldClock"))
                    return WorldClockTemplate;
                if ((item as HubPageDataItem).UniqueId.StartsWith("More"))
                    return MoreTemplate;
            }
            return base.SelectTemplateCore(item, container);

        }
    }
}
